package cn.edu.scau.cmi.tangqingning.adapter.objectAdapter;

import cn.edu.scau.cmi.tangqingning.adapter.hotel.GermanHotel;
import cn.edu.scau.cmi.tangqingning.adapter.plug.GBPlugImpl;
import cn.edu.scau.cmi.tangqingning.adapter.plug.GBPlugInterface;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.TextArea;

public class ObjectAdapterController {

	@FXML
    private TextArea textArea;

	GermanHotel hotel = new GermanHotel();

    @FXML
    void onUsingGBPlugClick(ActionEvent event) {
    	GBPlugInterface gbPlugIn = new GBPlugImpl();

		ObjectAdapter adapter = new ObjectAdapter(gbPlugIn);
    	hotel.setAdapter(adapter);
    	this.textArea.setText("use chinese plug with DBAdapter");
    }

    @FXML
    void onChargeClick(ActionEvent event) {
    	if(hotel.dBPlugIn == null) {
    		this.textArea.setText("can't use non-german plug");
    	} else {
    		this.textArea.setText(hotel.charge());
    	}

    }

}

